﻿<cfsilent>
	<cfscript>
		
		stringAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");

		event.setArg("pageTitle", "学生调查问卷 - 在线调查问卷详细");
		
		questionId = event.getArg("QSN");
		
		currentTab = event.getArg("TabID", "labDetail");
		
		passArgs = structNew();
		structInsert( passArgs, "QSN", questionId, true );
		structInsert( passArgs, "QueID", questionId, true );

		sql = "	SELECT
					q.date_end,q.title,q.date_start,q.grade_allowed,q.institute_allowed,q.gender_allowed
				FROM
					t_questionnaire q
				WHERE
					q.qsn_id = :questionId ";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "questionId", value = questionId, cfsqltype = "cf_sql_char");
		rs_quesEntity = queryObj.execute(sql = sql).getResult();
		
		sql = "	SELECT
					a.quo_id,a.question,a.measure,
					(SELECT COUNT(*) FROM t_vote_response b WHERE a.quo_id = b.quo_id AND b.answer = 'E') count_e,
					(SELECT COUNT(*) FROM t_vote_response b WHERE a.quo_id = b.quo_id AND b.answer = 'G') count_g,
					(SELECT COUNT(*) FROM t_vote_response b WHERE a.quo_id = b.quo_id AND b.answer = 'S') count_s,
					(SELECT COUNT(*) FROM t_vote_response b WHERE a.quo_id = b.quo_id AND b.answer = 'Y') count_y,
					(SELECT COUNT(*) FROM t_vote_response b WHERE a.quo_id = b.quo_id AND b.answer = 'N') count_n
				FROM
					t_quota a
				WHERE
					a.qsn_id = :sheetId 
				ORDER BY
					a.quo_idx";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "sheetId", value = questionId, cfsqltype = "cf_sql_char");
		rs_quota = queryObj.execute(sql = sql).getResult();
		
		sql = "	SELECT
					r.stu_id
				FROM
					t_respondents r
				WHERE
					r.qsn_id = :questionId 
					AND
					r.state = 'S'
				ORDER BY
					r.stu_id";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "questionId", value = questionId, cfsqltype = "cf_sql_char");
		rs_studentIds = queryObj.execute(sql = sql).getResult();
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
            <div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('voteList')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">调查问卷库</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>问卷详细
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="findStudent">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labDetail">class="active"</cfif> id="labDetail" tabTarget="Detail">问卷详细情况</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
				
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
				
					});
					// -->
					//]]>
				</script>
				
				<div id="Detail" class="tabContent">
					
					<div class="noticeBlock">

						<!--- 如果问卷没有结束 --->
						<div class="operation">
							<cfif rs_quesEntity.date_end gte dateFormat(now(), "YYYYMMDD")>
								<a class="uiButton" href="<cfoutput>#buildURL('voteSetupWizard', passArgs)#</cfoutput>"><i class="mrs img btnAdd"></i><span class="uiButtonText">调整问卷</span></a>
								<a class="uiButton" href="<cfoutput>#buildURL('voteRemoveDo', passArgs)#</cfoutput>"><i class="mrs img btnClear"></i><span class="uiButtonText">删除问卷</span></a>
								<cfelse>
								<a class="uiButton" href="<cfoutput>#buildURL('voteDetailPrint', passArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印结果</span></a>
							</cfif>
						</div>
						
						<h3><cfoutput>#stringAdvice.XHTMLSafeFormat( rs_quesEntity.title )#</cfoutput></h3>
						<p><span class="img icon16x16 message"></span>
							问卷调查时间 <em><cfoutput>#datetimeAdvice.formatDateString( rs_quesEntity.date_start )#</cfoutput></em> 至 <em><cfoutput>#datetimeAdvice.formatDateString( rs_quesEntity.date_end )#</cfoutput></em> 
							参与调查范围:
							<cfif rs_quesEntity.grade_allowed eq "NOP" and rs_quesEntity.institute_allowed eq "NOP" and rs_quesEntity.gender_allowed eq "NOP">
									指定部分学生
								<cfelse>
									年级: 
									<cfif rs_quesEntity.grade_allowed eq "ALL">
										全部
										<cfelse>
										<em><cfoutput>#rs_quesEntity.grade_allowed#</cfoutput></em>
									</cfif>
									学院: 
									<cfif rs_quesEntity.institute_allowed eq "ALL">
										全部
										<cfelse>
                                        <cfset sql = "SELECT t.institute_short FROM t_institute t WHERE t.institute_id IN (:depIds ) ORDER BY t.institute_short"/>
										<cfset queryObj = new Query(datasource = application.dnsSlave) />
                                        <cfset queryObj.addParam(name = "depIds", value = rs_quesEntity.institute_allowed, cfsqltype = "cf_sql_varchar", list = true)/>
                                        <cfset rs_instituteNames = queryObj.execute(sql = sql).getResult() />
                                        <cfoutput>#valueList(rs_instituteNames.institute_short,", ")#</cfoutput>
									</cfif>
									性别: 
									<cfif rs_quesEntity.gender_allowed eq "ALL">
										全部
										<cfelseif rs_quesEntity.gender_allowed eq "1">
										男生
										<cfelseif rs_quesEntity.gender_allowed eq "2">
										女生
									</cfif>
							</cfif>
							, 有效回执问卷 <em><cfoutput>#rs_studentIds.recordCount#</cfoutput></em> 份.
						</p>
						<hr/>
					</div>
					
					<div class="noticeBlock">
						<h2>指标体系评分统计</h2>
						<p>以下是该问卷各项指标体系评分统计结果</p>
					</div>
					
					<cfset row = 0 />
					<table class="UItable">
						<tr class="cellBorder">
							<td align="center" width="20">序</td>
							<td>问题</td>
							<td width="200" align="center">各指标评价情况</td>
							<td align="center" width="70">综合</td>
						</tr>
						<!---<cfloop array="#quotaArray#" index="quota">--->
						<cfloop query="rs_quota">
							<cfset row++ />
							
							<cfswitch expression="#rs_quota.measure#">
								<cfcase value="L1">
									<!--- 7-Y 8-N --->
									<cfset summarySet = [ rs_quota.count_y, rs_quota.count_n ] />
								</cfcase>
								<cfcase value="L3">
									<!--- 6-S 7-Y 8-N --->
									<cfset summarySet = [ rs_quota.count_s, rs_quota.count_y, rs_quota.count_n ] />
								</cfcase>
								<cfcase value="L4">
									<!--- 4-E 5-G 7-Y 8-N  --->
									<cfset summarySet = [ rs_quota.count_e, rs_quota.count_g, rs_quota.count_y, rs_quota.count_n ] />
								</cfcase>
							</cfswitch>
							<cfset result = numberFormat( 100 * mathAdvice.getSatisfactionDegree( summarySet ), "__.____" ) />
							
							<tr class="cellBorder">
								<td align="center"><span class="number"><cfoutput>#row#</cfoutput></span></td>
								<td><cfoutput>#stringAdvice.XHTMLSafeFormat( rs_quota.question )#</cfoutput></td>
								<td class="quota">
								<cfswitch expression="#rs_quota.measure#">
									<cfcase value="L1">
										<table>
											<tr>
												<td>是</td>
												<td>否</td>
											</tr>
											<!--- 7-Y 8-N --->
											<tr class="valued">
												<td><cfif rs_quota.count_y><cfoutput>#rs_quota.count_y#</cfoutput><cfelse>-</cfif></td>
												<td><cfif rs_quota.count_n><cfoutput>#rs_quota.count_n#</cfoutput><cfelse>-</cfif></td>
											</tr>
										</table>
									</cfcase>
									<cfcase value="L3">
										<table>
											<tr>
												<td>满意</td>
												<td>基本满意</td>
												<td>不满意</td>
											</tr>
											<!--- 6-S 7-Y 8-N --->
											<tr class="valued">
												<td><cfif rs_quota.count_s><cfoutput>#rs_quota.count_s#</cfoutput><cfelse>-</cfif></td>
												<td><cfif rs_quota.count_y><cfoutput>#rs_quota.count_y#</cfoutput><cfelse>-</cfif></td>
												<td><cfif rs_quota.count_n><cfoutput>#rs_quota.count_n#</cfoutput><cfelse>-</cfif></td>
											</tr>
										</table>
									</cfcase>
									<cfcase value="L4">
										<table>
											<tr>
												<td>优秀</td>
												<td>较好</td>
												<td>普通</td>
												<td>不好</td>
											</tr>
											<!--- 4-E 5-G 7-Y 8-N  --->
											<tr class="valued">
												<td><cfif rs_quota.count_e><cfoutput>#rs_quota.count_e#</cfoutput><cfelse>-</cfif></td>
												<td><cfif rs_quota.count_g><cfoutput>#rs_quota.count_g#</cfoutput><cfelse>-</cfif></td>
												<td><cfif rs_quota.count_y><cfoutput>#rs_quota.count_y#</cfoutput><cfelse>-</cfif></td>
												<td><cfif rs_quota.count_n><cfoutput>#rs_quota.count_n#</cfoutput><cfelse>-</cfif></td>
											</tr>
										</table>
									</cfcase>
								</cfswitch>
								</td>
								<td align="center"><span class="numeric"><cfif result gt 0><cfoutput>#result#</cfoutput> %<cfelse>-</cfif></span></td>
							</tr>
						</cfloop>
					</table>
					
				</div>
			
			</div>
		</li>
	</ul>
</div>